"use strict";
//ts 1\定义类
// class Person {
//   name: string
//   age: number
//   constructor(n: string, a: number) {
//     this.name = n
//     this.age = a
//   }
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
//   getInfo(): any {
//     return `我叫${this.name},今年${this.age}岁`
//   }
//   setInfo(n: string, a: number): void {
//     this.name = n
//     this.age = a
//   }
// }
// let p = new Person('smr', 25)
// console.log(p.getInfo())
// p.setInfo('sss', 26)
// console.log(p.getInfo())
//ts 2\继承
var Person = /** @class */ (function () {
    function Person(n, a) {
        this.name = n;
        this.age = a;
    }
    Person.prototype.run = function () {
        return this.name + "\u5728\u8FD0\u52A8";
    };
    return Person;
}());
var p = new Person('smr');
console.log(p.run());
var Web = /** @class */ (function (_super) {
    __extends(Web, _super);
    function Web(name) {
        //super 调用父类的属性
        return _super.call(this, name) || this;
    }
    Web.prototype.work = function () {
        return this.name + " \u5728\u5DE5\u4F5C";
    };
    return Web;
}(Person));
var w = new Web('sss');
console.log(w.run());
console.log(w.name);
//ts 3\修饰符 protected   public  默认为public
//1\protected  与 private 的区别就是可以在派生类中访问
/* class Person {
    protected name: string;
    constructor(name: string) {
        this.name = name;
    }
}
let p = new Person('smr');
//不能在声明它的类的外部访问 但可以在派生类中仍然可以访问
console.log(p.name); */
/* class Person {
    protected name: string;
    constructor(name: string) {
        this.name = name;
    }
}
class Web extends Person {
    constructor(name: string) {
        super(name)
    }
    run(): string {
        return `${this.name}在工作`
    }
}

let w = new Web('smr');
console.log(w.run());
console.log(w.name); //也是外部访问 所以出错 */
//构造函数constructor也可以被标记成protected。 这意味着这个类不能在包含它的类外被实例化，但是能被继承。
/* class Person {
    protected name: string;
    protected constructor(name: string) {
        this.name = name;
    }
}
let p = new Person('sss') //类“Person”的构造函数是受保护的，仅可在类声明中访问 */
/* class Person {
    protected name: string;
    protected constructor(name: string) {
        this.name = name;
    }
}

class Web extends Person {
    constructor(name: string) {
        super(name)
    }
    run(): void {
        console.log(`${this.name}在飞翔`);
    }
}

let w = new Web('xxxx');
w.run(); */
//2\ private
/* class Person {
    private name: string;
    constructor(name:string) {
        this.name = name;
    }
    run(): string {
        return `${this.name}在奔跑`
    }
}

let p = new Person('smr');
//不能在声明它的类的外部访问 只能内部访问
// console.log(p.name);
console.log(p.run()); */
//不能在声明它的类的外部访问 也不可以在派生类中访问
/* class Person {
    private name: string;
    constructor(name: string) {
        this.name = name;
    }
}

class Web extends Person {
    constructor(name: string) {
        super(name)
    }
    run(): void {
        console.log(`${this.name}`);  //error
    }
} */
